package mulMan.gui.view;

import java.util.List;
import java.util.Observable;
import java.util.Observer;

import javax.swing.DefaultListModel;

import mulMan.domain.Playlist;

public class PlaylistListModel extends DefaultListModel implements Observer{
	
	private static final long serialVersionUID = 1731610339942028525L;
	
	public PlaylistListModel(List<Playlist> playlistModels) {
		super();
		for (Playlist iterator : playlistModels) {
			addElement(iterator);
		}
	}
	
	public void addElement(Playlist element) {
		super.addElement(element);
		((Observable) element).addObserver(this);
	}

	public void update(Observable arg0, Object arg1) {
		fireContentsChanged(this, indexOf(arg0), indexOf(arg0));
	}
}
